<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>Create Order</title>
	<link rel="stylesheet" href="${pageContext.request.contextPath}/resources/web.css" type="text/css" media="screen, projection"/>
</head>

<body>
<div class="container">
	<%@include file="../common/header.jsp" %>
	<br/>
	<br/>
    <c:if test="${order.id == null}">
        <h2>Create Order</h2>
    </c:if>
    <c:if test="${order.id != null}">
        <h2>Update Order</h2>
    </c:if>
</div>
    
    <div class="span-12last">	
		<form:form modelAttribute="order" action="delete" method="post">
            <table width="100%" border="1" cellpadding="2" cellspacing="0">
                <thead>
                    <tr>
                        <th>&nbsp;</th>
                        <th>Image</th>
                        <th>Name</th> 
                        <th>Price</th>
                        <th>Quantity</th>
                        <th>Total</th>
                    </tr>
                </thead>
                
                <tbody>                	
                    <c:forEach items="${order}" var="order">
                    <tr>
                        <td><input type="checkbox" name="id" value="${order.id}"/></td>
                        <td>
                   			<img src="<c:url value="/images/${order.product.filename}"/>" />
						</td>
                        <td><c:out value="${order.product.name}"/></td>
                        <td><c:out value="${order.product.price}"/></td>
                        <td><c:out value="${order.product.quantity}"/></td>
                      	<td><c:out value="${order.total}"/></td>
                    <tr/>
                    </c:forEach>    
                </tbody>
            </table>
            <div class="save">
            <input type="button" value="Create Product" onclick="window.location.href='create';"/> &nbsp;&nbsp; <input type="submit" value="Delete selected product"/>
			</div>
		</form:form>
		
		<form:form modelAttribute="order" action="save" method="post"  class="cleanform ">
		  	<fieldset class="info">		
			<form:label for="status" path="status" cssErrorClass="error">Color</form:label>
				<form:select path="status">
					<form:option value="delivered">Delivered</form:option>
					<form:option value="pending">Pending</form:option>
				</form:select>
			</fieldset>
		</form:form>
	</div>
	
	<div class="footer">
	<%@include file="../common/footer.jsp" %>
	</div>
</body>

</html>